package appconfig

import (
	"fmt"

	"github.com/spf13/viper"
)

type AppConfig struct {
	Mysql struct {
		User     string
		Password string
		Host     string
		Port     int
		Database string
	}
	Redis struct {
		Host     string
		Port     int
		Password string
		Database int
	}
}

var AppConf AppConfig

func Init() {

	viper.SetConfigFile("../appconfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic(err)
	}
	err = viper.Unmarshal(&AppConf)
	if err != nil {
		panic(err)
	}
	fmt.Println("成功读取配置文件", AppConf)

}
